const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    role: 1,
    bankcardList: []
  },

  onLoad(options) {
    let role = app.globalData.userInfo.role;
    this.setData({
      role
    });
  },

  getData() {
    let api = "getBankcardMarketPage";
    if (this.data.role != 1) {
      api = "getBankcardUserPage";
    }
    wx.showLoading({
      title: "获取中..."
    });
    wx.$apis[api]({
      asc: true,
      columns: [],
      current: 1,
      size: 100,
      companyId: app.globalData.userInfo.companyData.companyId
    }).then((res) => {
      if (res.data) {
        this.setData({
          bankcardList: res.data.records
        });
      }
    });
  },
  toAddBankCard() {
    wx.navigateTo({
      url: "/pages/management/add-bank-card/index"
    });
  },
  // 修改
  onDetail(e) {
    let id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: "/pages/management/add-bank-card/index?id=" + id
    });
  },
  onShow() {
    this.getData();
  }
});
